///\todo upgrade

//////////////////////////////////////////////////////////////////////////////////
//                                                                              //
//  This file is part of the buola project (https://code.google.com/p/buola/).  //
//                                                                              //
//  Copyright(c) 2007-2012 Xavi Gratal                                          //
//  gratal AT gmail DOT com                                                     //
//                                                                              //
//  Buola is free software: you can redistribute it and/or modify               //
//  it under the terms of the GNU General Public License as published by        //
//  the Free Software Foundation, either version 3 of the License, or           //
//  (at your option) any later version.                                         //
//                                                                              //
//  Buola is distributed in the hope that it will be useful,                    //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of              //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               //
//  GNU General Public License for more details.                                //
//                                                                              //
//  You should have received a copy of the GNU General Public License           //
//  along with buola.  If not, see <http://www.gnu.org/licenses/>.              //
//                                                                              //
//////////////////////////////////////////////////////////////////////////////////

#ifndef _BUOLA_IMAGE_OPERATOR_BASE_H_
#define _BUOLA_IMAGE_OPERATOR_BASE_H_

#include <buola/image/format.h>

namespace buola { namespace img {

struct CImageOp {};
    
template<typename tLH,typename tRH,typename tOp>
class CBinaryOp : public CImageOp
{
public:
    CBinaryOp(const tLH &pLH,const tRH &pRH,const tOp &pOp)
        :   mLH(pLH)
        ,   mRH(pRH)
        ,   mOp(pOp)
    {
    }

private:
    tLH mLH;
    tRH mRH;
    tOp mOp;
};

template<typename tLH,typename tOp>
class CUnaryOp : public CImageOp
{
public:
    CUnaryOp(const tLH &pLH,const tOp &pOp)
        :   mLH(pLH)
        ,   mOp(pOp)
    {
    }

private:
    tLH mLH;
    tOp mOp;
};

template<typename tType>
struct MIsImageOperand
{
    typedef ODecay<tType> tDecayed;
    static const bool value=MIsImage<tDecayed>::value||
                             MIsView<tDecayed>::value||
                             std::is_base_of<CImageOp,tDecayed>::value;
};

template<typename tLH,typename tRH,typename tOp>
struct MBinaryOpResult<tLH,tRH,tOp>
{
    typedef CBinaryOp<ODecay<tLH>,ODecay<tRH>,tOp> type;
};

template<typename tLH,typename tOp>
struct MUnaryOpResult<tLH,tOp>
{
    typedef CUnaryOp<ODecay<tLH>,tOp> type;
};

/*namespace image*/ } /*namespace buola*/ }

#endif
